Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

597
Vistas
JS fetch() | How to hide console error on 404?

I'm using javascripts fetch() method to check if a file on the server exists, if not i want to fallback to fetching another default file. In this article I allready learned that JS does not throw an error if the request results in an 404 Error, but sets response.ok to false.

So my code looks like this now:

let resp;

resp = await fetch("url1"); //check for custom file at url1
if (!resp.ok) { resp = await fetch("url2"); } //if not found use default file at url2

It work's as expected, but: if the first request returns a 404-Status Code the console allways shows an error for the 404 Response. I dont want to see the Error in the console because it looks like an application error, but just means that the default file was loaded... Any Ideas how to fix this? I'm using Chrome and it looks like this:

Screenshot - error in Chrome's console

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda